<template>
    <consum-list-component v-if="'agent' === maxRole" :init-param=" {all :false,role:maxRole}"></consum-list-component>
    <consum-list-component v-else-if="'channelBusiness' === maxRole" :init-param=" {all :false,role:maxRole}"></consum-list-component>
    <consum-list-component v-else-if="'admin' === maxRole" :init-param=" {all :true,role:maxRole}"></consum-list-component>
</template>

<script>
import ConsumListComponent from "@/views/models/order/consumComponent";
import {mapState} from "vuex";
export default {
    name: "SkuConsumList",
    components: {ConsumListComponent},
    mixins: [],

    data() {
        return {
            maxRole: "",
        }
    },
    computed: {
        ...mapState({
            userInfo: state => state.currentUser,
            userRole: state => state.user,
        })
    },
    created() {
        this.getCurrentUserMaxRole();
    },
    methods: {
        getCurrentUserMaxRole() {
            if ((this.userInfo.userTypes.includes("admin")) || this.userRole.roles.includes("maxAdmin")) {
                this.maxRole = "admin";
            } else if (this.userInfo.userTypes.includes("teacher")) {
                this.maxRole = "teacher";
            } else if (this.userInfo.userTypes.includes("agent")) {
                this.maxRole = "agent";
            } else if (this.userInfo.userTypes.includes("channelBusiness")) {
                this.maxRole = "channelBusiness";
            }
        },
    }
}

</script>

